package cn.virens.common.project.generator.database.utils;

import cn.virens.common.util.exception.APIException;
import org.dromara.hutool.core.text.CharSequenceUtil;

public class PathUtil {
    private static final String reg = "/+|\\.|\\\\+";

    /**
     * 生成路径参数
     */
    public static String path(String ps) throws APIException {
        return ps != null ? ps.replaceAll(reg, "/") : "";
    }

    /**
     * 生成权限标识
     */
    public static String perm(String ps) throws APIException {
        return ps != null ? ps.replaceAll(reg, ":") : "";
    }

    /**
     * 下划线转驼峰
     */
    public static String camel0(CharSequence str) throws APIException {
        return CharSequenceUtil.upperFirst(camel1(str));
    }

    /**
     * 下划线转驼峰
     */
    public static String camel1(CharSequence str) throws APIException {
        return CharSequenceUtil.toCamelCase(str);
    }
}
